package org.onvivals.module.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.onvivals.common.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.util.List;

/**
 * 菜单
 */
@Schema(description = "菜单")
@Data
@TableName(value = "sys_menu")
public class SysMenu extends BaseEntity<SysMenu> {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 菜单id
     */
    @TableId(value = "menu_id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using= ToStringSerializer.class)
    @Schema(description = "菜单id")
    private Long menuId;

    /**
     * 上级id, 0是顶级
     */
    @TableField(value = "parent_id")
    @Schema(description = "上级id, 0是顶级")
    @JsonSerialize(using= ToStringSerializer.class)
    private Long parentId;

    /**
     * 菜单名称
     */
    @TableField(value = "title")
    @Schema(description = "菜单名称")
    private String title;

    /**
     * 菜单路由地址
     */
    @TableField(value = "`path`")
    @Schema(description = "菜单路由地址")
    private String path;

    /**
     * 菜单组件地址, 目录可为空
     */
    @TableField(value = "component")
    @Schema(description = "菜单组件地址, 目录可为空")
    private String component;

    /**
     * 类型, 0菜单, 1按钮
     */
    @TableField(value = "menu_type")
    @Schema(description = "类型, 0菜单, 1按钮")
    private Integer menuType;

    /**
     * 排序号
     */
    @TableField(value = "sort_number")
    @Schema(description = "排序号")
    private Integer sortNumber;

    /**
     * 权限标识
     */
    @TableField(value = "authority")
    @Schema(description = "权限标识")
    private String authority;

    /**
     * 菜单图标
     */
    @TableField(value = "icon")
    @Schema(description = "菜单图标")
    private String icon;

    /**
     * 是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)
     */
    @TableField(value = "hide")
    @Schema(description = "是否隐藏, 0否, 1是(仅注册路由不显示在左侧菜单)")
    private Integer hide;

    /**
     * 其它路由元信息
     */
    @TableField(value = "meta")
    @Schema(description = "其它路由元信息")
    private String meta;

    @Schema(description = "子菜单")
    @TableField(exist = false)
    private List<SysMenu> children;

    @Schema(description = "角色权限树选中状态")
    @TableField(exist = false)
    private Boolean checked;
}
